package com.rdd.action

import org.apache.spark.{SparkConf, SparkContext}

object testUnion {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("testUnion").setMaster("local")
    val sc = new SparkContext(conf)

    val t1 = sc.textFile("src\\main\\scala\\join1.txt")
    val t2 = sc.textFile("src\\main\\scala\\join2.txt")
    /**
     * union 并集
     */
    val unit = t1.union(t2)
    /**
     * intersection 交集
     */
    val value1 = t1.intersection(t2)
    /**
     * subtract 差集
     */
    val value2 = t1.subtract(t2)

    unit.foreach(println)
    value1.foreach(println)
    value2.foreach(println)

//    val flow = sc.parallelize(List(("001001003001",2),("001001001001",1),("001002001001",1)))
//    val org = sc.parallelize(List(("001001003001",2),("001001001001",2),("001002001001",2)))
//    val u = flow.union(org)
//    u.foreach(println)

    sc.stop()
  }

}
